package com.goods.business.controller;

import com.goods.business.service.InStockService;
import com.goods.common.response.ResponseBean;
import com.goods.common.vo.business.InStockVO;
import com.goods.common.vo.system.PageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author jiaoyanlin
 * @Date 2021/11/10 11:21
 * @Description InStockController
 * 入库
 * /business/inStock/findInStockList?pageNum=1&pageSize=10&status=0
 */
@RestController
@RequestMapping("/business/inStock")
public class InStockController {

    @Autowired
    private InStockService inStockService;

    @GetMapping("/findInStockList")

    public ResponseBean<PageVO<InStockVO>> findInStockList(@RequestParam Map<String,Object> map){
        PageVO<InStockVO> pageVO =  inStockService.findInStockList(map);
        return ResponseBean.success(pageVO);
    }

    ///detail/112?pageNum=1
    @GetMapping("/detail/{id}")
    public ResponseBean<PageVO<InStockVO>> detail(@PathVariable Long id,@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum){
        PageVO <InStockVO> pageVO = inStockService.detail(id,pageNum);
        return ResponseBean.success(pageVO);
    }
    @PutMapping("/remove/{id}")
    public ResponseBean remove(@PathVariable Long id){
        inStockService.remove(id);
        return ResponseBean.success();
    }
    @PutMapping("/back/{id}")
    public ResponseBean back(@PathVariable Long id){
        inStockService.back(id);
        return ResponseBean.success();
    }
    @DeleteMapping("/delete/{id}")
    public ResponseBean delete(@PathVariable Long id){
        inStockService.delete(id);
        return ResponseBean.success();
    }
   @PostMapping("/addIntoStock")
    public ResponseBean addIntoStock(@RequestBody Map<String,Object> map){
       System.out.println("map = " + map);
       inStockService.addIntoStock(map);
        return ResponseBean.success();

    }


    @PutMapping("/publish/{id}")
    public ResponseBean publish(@PathVariable Long id){
        inStockService.publish(id);
        return ResponseBean.success();
    }
}
